﻿<s:SurfaceWindow
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:s="http://schemas.microsoft.com/surface/2008"
  xmlns:controls="clr-namespace:WPFMitsuControlsv2;assembly=WPFMitsuControlsv2"
  xmlns:local="clr-namespace:BookSurfaceDemoApp"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:Microsoft_Surface_Presentation_Generic="clr-namespace:Microsoft.Surface.Presentation.Generic;assembly=Microsoft.Surface.Presentation.Generic" 
  x:Class="BookSurfaceDemoApp.SurfaceWindow1"
  Title="BookSurfaceDemoApp"
	Loaded="OnLoaded"
    >

  <s:SurfaceWindow.Resources>
    <ImageBrush x:Key="WindowBackground" Stretch="None" Opacity="0.6" ImageSource="pack://application:,,,/Resources/WindowBackground.jpg"/>

    <local:CustomBookmarkProperties x:Key="CustBookmarkRed" Color="Red" Details="Details for the first bookmark" />

    <Style x:Key="CustomListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
      <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
      <Setter Property="Padding" Value="2,0,0,0"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListBoxItem}">
            <Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
              <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>

      <Style.Triggers>
        <!-- Put nothing to remove the other triggers -->
      </Style.Triggers>

    </Style>

    <Style x:Key="customBookItemStyle" TargetType="{x:Type local:CustomBookItem}">

      <Setter Property="Margin" Value="0" />
      <Setter Property="ClipToBounds" Value="false" />
      <Setter Property="Width" Value="50" />
      <Setter Property="Height" Value="35" />
      <Setter Property="Template">
        <Setter.Value>

          <ControlTemplate TargetType="{x:Type local:CustomBookItem}">
            <ControlTemplate.Resources>

              <DrawingBrush x:Key="Couvercle" Stretch="Uniform">
                <DrawingBrush.Drawing>
                  <DrawingGroup>
                    <DrawingGroup.Children>
                      <GeometryDrawing Geometry="F1 M 123.881,24.1949C 123.881,32.2029 96.1955,38.6946 62.0432,38.6946C 27.8908,38.6946 0.204895,32.2029 0.204895,24.1949C 0.204895,24.0114 0.219421,23.8288 0.248169,23.6471L 0.188965,23.6474C 0.188965,23.6474 0.217346,23.5927 0.276917,23.4888C 0.527588,22.2628 1.42767,21.0767 2.89816,19.949C 8.62155,13.4072 24.5359,0.453522 60.9598,0.188995C 60.9599,0.188995 104.421,-0.251923 121.68,20.3463C 122.682,21.2024 123.358,22.0901 123.731,23.0849L 123.703,23.085C 123.821,23.4513 123.881,23.8214 123.881,24.1949 Z ">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <RadialGradientBrush RadiusX="0.946708" RadiusY="2.89756" Center="0.1213,0.304844" GradientOrigin="0.1213,0.304844">
                            <RadialGradientBrush.GradientStops>
                              <GradientStop Color="#FFF4F4F4" Offset="0"/>
                              <GradientStop Color="#FF1F1C42" Offset="1"/>
                            </RadialGradientBrush.GradientStops>
                            <RadialGradientBrush.RelativeTransform>
                              <TransformGroup>
                                <SkewTransform CenterX="0.1213" CenterY="0.304844" AngleX="11.9109" AngleY="0"/>
                                <RotateTransform CenterX="0.1213" CenterY="0.304844" Angle="13.2145"/>
                              </TransformGroup>
                            </RadialGradientBrush.RelativeTransform>
                          </RadialGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                      <GeometryDrawing Geometry="F1 M 62.3179,4.48917C 73.0531,4.48917 81.7554,6.30795 81.7554,8.55167C 81.7554,10.7953 73.0529,12.6142 62.3179,12.6142C 51.5829,12.6142 42.8804,10.7953 42.8804,8.55167C 42.8804,6.30795 51.5826,4.48917 62.3179,4.48917 Z ">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <LinearGradientBrush StartPoint="1.08842,0.628204" EndPoint="2.00956,0.628204">
                            <LinearGradientBrush.RelativeTransform>
                              <TransformGroup>
                                <SkewTransform CenterX="1.08842" CenterY="0.628204" AngleX="4.88658" AngleY="0"/>
                                <RotateTransform CenterX="1.08842" CenterY="0.628204" Angle="185.11"/>
                              </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <LinearGradientBrush.GradientStops>
                              <GradientStop Color="#FFABA5C0" Offset="0"/>
                              <GradientStop Color="#FF1D1A46" Offset="1"/>
                            </LinearGradientBrush.GradientStops>
                          </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                      <GeometryDrawing Geometry="F1 M 81.5262,8.17667C 82.3387,10.5517 78.4243,8.20883 78.4243,8.20883C 73.0054,5.34332 61.7476,5.31985 61.7476,5.31985C 53.9132,5.36014 49.4567,6.39334 46.5887,8.11417C 44.4012,9.4267 42.9637,8.1142 42.9637,8.1142C 42.9637,8.1142 45.2762,0.364166 61.4637,0.280853C 61.4637,0.280853 78.6823,-0.136292 81.5262,8.17667 Z ">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <LinearGradientBrush StartPoint="0.497218,-0.262261" EndPoint="1.57573,-0.262261">
                            <LinearGradientBrush.RelativeTransform>
                              <TransformGroup>
                                <SkewTransform CenterX="0.497218" CenterY="-0.262261" AngleX="8.00482" AngleY="0"/>
                                <RotateTransform CenterX="0.497218" CenterY="-0.262261" Angle="89.542"/>
                              </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <LinearGradientBrush.GradientStops>
                              <GradientStop Color="#FFF4F4F4" Offset="0"/>
                              <GradientStop Color="#FF1F1C42" Offset="1"/>
                            </LinearGradientBrush.GradientStops>
                          </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                    </DrawingGroup.Children>
                  </DrawingGroup>
                </DrawingBrush.Drawing>
              </DrawingBrush>

              <DrawingBrush x:Key="Poubelle" Stretch="Uniform">
                <DrawingBrush.Drawing>
                  <DrawingGroup>
                    <DrawingGroup.Children>
                      <GeometryDrawing Geometry="F1 M 9.82901,16.4227C -19.7751,104.918 28.0311,163.693 28.3598,164.066C 28.3866,169.595 47.5495,174.089 71.188,174.089C 94.8266,174.089 113.989,169.595 114.002,164.107C 114.341,164.028 163.419,109.698 132.778,15.9788">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <LinearGradientBrush StartPoint="-0.14106,0.221549" EndPoint="1.13897,0.221549">
                            <LinearGradientBrush.GradientStops>
                              <GradientStop Color="#FFF4F4F4" Offset="0"/>
                              <GradientStop Color="#FF1F1C42" Offset="1"/>
                            </LinearGradientBrush.GradientStops>
                          </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                      <GeometryDrawing Brush="#FF898989" Geometry="M 71.1511,0.188965C 105.304,0.188965 132.989,6.68073 132.989,14.6888C 132.989,22.6968 105.303,29.1886 71.1511,29.1886C 36.9988,29.1886 9.31281,22.6968 9.31281,14.6888C 9.31281,6.68073 36.9986,0.188965 71.1511,0.188965 Z M 70.727,1.01202C 102.76,1.01202 128.727,7.10077 128.727,14.6118C 128.727,22.1227 102.759,28.2115 70.727,28.2115C 38.6945,28.2115 12.727,22.1227 12.727,14.6118C 12.727,7.10077 38.6943,1.01202 70.727,1.01202 Z ">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                      </GeometryDrawing>
                      <GeometryDrawing Geometry="F1 M 111.694,153.322C 110.349,156.715 106.918,159.638 102.877,158.594L 102.877,158.594C 99.7359,157.782 97.6052,154.951 97.1939,151.32C 120.047,98.9838 116.542,43.4887 116.519,43.5919C 117.445,39.0936 121.389,36.319 125.396,37.3686C 130.889,38.5095 131.052,45.4667 131.052,45.4667C 131.052,45.4667 134.557,100.962 111.695,153.343">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <LinearGradientBrush StartPoint="0.464862,0.5346" EndPoint="1.30737,0.5346">
                            <LinearGradientBrush.RelativeTransform>
                              <TransformGroup>
                                <SkewTransform CenterX="0.464862" CenterY="0.5346" AngleX="-24.2618" AngleY="0"/>
                                <RotateTransform CenterX="0.464862" CenterY="0.5346" Angle="2.23647"/>
                              </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <LinearGradientBrush.GradientStops>
                              <GradientStop Color="#FF343250" Offset="0"/>
                              <GradientStop Color="#FFC5C3C3" Offset="1"/>
                            </LinearGradientBrush.GradientStops>
                          </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                      <GeometryDrawing Geometry="F1 M 33.1689,152.199C 34.5141,155.592 37.9454,158.514 41.9858,157.47L 41.9858,157.47C 45.1272,156.659 47.2579,153.828 47.6692,150.196C 24.8166,97.8605 28.3213,42.3654 28.3442,42.4685C 27.4182,37.9702 23.4738,35.1956 19.4673,36.2452C 13.9741,37.3861 13.8109,44.3434 13.8109,44.3433C 13.8109,44.3433 10.3062,99.8384 33.1679,152.22">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <LinearGradientBrush StartPoint="-0.0305633,0.511383" EndPoint="0.690112,0.511383">
                            <LinearGradientBrush.RelativeTransform>
                              <TransformGroup>
                                <SkewTransform CenterX="-0.0305633" CenterY="0.511383" AngleX="32.8287" AngleY="0"/>
                                <RotateTransform CenterX="-0.0305633" CenterY="0.511383" Angle="-3.26914"/>
                              </TransformGroup>
                            </LinearGradientBrush.RelativeTransform>
                            <LinearGradientBrush.GradientStops>
                              <GradientStop Color="#FF393754" Offset="0"/>
                              <GradientStop Color="#FFC5C3C3" Offset="1"/>
                            </LinearGradientBrush.GradientStops>
                          </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                      <GeometryDrawing Geometry="F1 M 28.2895,164.332C 28.2895,164.332 70.1228,178.916 113.873,164.166">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                      </GeometryDrawing>
                      <GeometryDrawing Geometry="F1 M 70.5246,1.08725C 102.557,1.08725 128.525,7.17615 128.525,14.6873C 128.525,22.1983 102.557,28.2872 70.5246,28.2872C 38.492,28.2872 12.5244,22.1983 12.5244,14.6873C 12.5244,7.17615 38.4919,1.08725 70.5246,1.08725 Z ">
                        <GeometryDrawing.Pen>
                          <Pen Thickness="0.377953" LineJoin="Round" Brush="#FF000000"/>
                        </GeometryDrawing.Pen>
                        <GeometryDrawing.Brush>
                          <LinearGradientBrush StartPoint="-0.00162979,0.499999" EndPoint="1.00163,0.499999">
                            <LinearGradientBrush.GradientStops>
                              <GradientStop Color="#FF15123C" Offset="0"/>
                              <GradientStop Color="#FFC5C3C3" Offset="1"/>
                            </LinearGradientBrush.GradientStops>
                          </LinearGradientBrush>
                        </GeometryDrawing.Brush>
                      </GeometryDrawing>
                    </DrawingGroup.Children>
                  </DrawingGroup>
                </DrawingBrush.Drawing>
              </DrawingBrush>
              <Storyboard x:Key="MangerStoryboard"/>

            </ControlTemplate.Resources>

            <Grid SnapsToDevicePixels="true" DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Header}">

              <Border 
                x:Name="PART_Border"
                VerticalAlignment="Stretch" Margin="0,5" RenderTransformOrigin="0.5,0.5">

                <Grid x:Name="PART_InnerGrid">
                  <TextBlock Text="{Binding Details, UpdateSourceTrigger=PropertyChanged}" TextTrimming="CharacterEllipsis" Margin="8,1,4,0" VerticalAlignment="Top" />

                  <StackPanel Orientation="Horizontal" TextBlock.FontSize="8" TextBlock.FontStyle="Italic" 
                              HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="0,0,6,1">
                    <TextBlock Text="p. " />
                    <TextBlock Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:BookItem}}, Path=PageIndex}" />
                  </StackPanel>

                  <s:SurfacePopup x:Name="PART_DeletePopup" AllowsTransparency="True" StaysOpen="False" PopupAnimation="Fade"
                                Placement="Top" PlacementTarget="{Binding ElementName=PART_InnerGrid}"
                                VerticalOffset="-20" HorizontalOffset="-10">

                    <s:SurfaceButton x:Name="PART_DeleteButton" Width="50" Height="64" Margin="0,20,0,0">
                      <s:SurfaceButton.Template>
                        <ControlTemplate TargetType="{x:Type s:SurfaceButton}">

                          <ContentPresenter />

                        </ControlTemplate>
                      </s:SurfaceButton.Template>

                      <Grid x:Name="grid" RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                          <TransformGroup>
                            <ScaleTransform/>
                            <SkewTransform/>
                            <RotateTransform/>
                            <TranslateTransform/>
                          </TransformGroup>
                        </Grid.RenderTransform>
                        <Grid.RowDefinitions>
                          <RowDefinition Height="0.059*" />
                          <RowDefinition Height="0.148*" />
                          <RowDefinition Height="0.145*" />
                          <RowDefinition Height="0.498*" />
                          <RowDefinition Height="0.15*" />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                          <ColumnDefinition Width="0.35*"/>
                          <ColumnDefinition Width="0.3*"/>
                          <ColumnDefinition Width="0.35*"/>
                        </Grid.ColumnDefinitions>
                        <Grid Grid.ColumnSpan="3" Grid.RowSpan="4" Background="{StaticResource Poubelle}" Grid.Row="1" />
                        <Path x:Name="path" Fill="Black" Stretch="Fill" RenderTransformOrigin="0.5,0.5" 
                                Data="M3.8737671,18.292784 C4.1472096,18.292784 4.3841929,18.393047 4.5847173,18.593571 C4.7852416,18.781942 4.8855038,19.018927 4.8855038,19.304522 C4.8855038,19.58404 4.7852416,19.821024 4.5847173,20.015471 C4.3781166,20.209919 4.1411328,20.307144 3.8737671,20.307144 C3.6064012,20.307144 3.3694179,20.209919 3.162817,20.015471 C2.9622924,19.821024 2.8620303,19.58404 2.8620303,19.304522 C2.8620303,19.018927 2.9622924,18.781942 3.162817,18.593571 C3.3633413,18.393047 3.6003246,18.292784 3.8737671,18.292784 z M4.0834064,6.8537779 C4.5452199,6.8537779 4.9796896,6.9145432 5.3868151,7.0360727 C5.7939401,7.1576033 6.1509347,7.3383789 6.4577975,7.5784006 C6.7646608,7.8184223 7.0062013,8.1176891 7.1824198,8.476203 C7.3586383,8.8347158 7.4467478,9.2509565 7.4467478,9.7249231 C7.4467478,10.174583 7.367753,10.575633 7.209764,10.928069 C7.0517755,11.280506 6.8527699,11.60408 6.6127481,11.89879 C6.3727264,12.193501 6.1129565,12.468462 5.8334374,12.723675 C5.5539188,12.978888 5.2941484,13.232581 5.0541267,13.484756 C4.814105,13.736931 4.6150999,13.999739 4.4571109,14.273182 C4.2991219,14.546623 4.2201276,14.84741 4.2201276,15.175541 C4.2201276,15.45506 4.2535481,15.708754 4.3203897,15.936623 C4.3872313,16.164492 4.4540725,16.35742 4.5209141,16.515409 L3.0534399,16.515409 C2.9987514,16.35742 2.9501395,16.152338 2.907604,15.900164 C2.8650684,15.647989 2.8438008,15.397333 2.8438008,15.148197 C2.8438008,14.759301 2.9212761,14.408383 3.0762267,14.095444 C3.2311776,13.782504 3.4241064,13.489313 3.6550131,13.215871 C3.88592,12.942429 4.1380949,12.67962 4.4115372,12.427445 C4.6849794,12.17527 4.9371543,11.920057 5.1680613,11.661807 C5.3989677,11.403556 5.5918965,11.133151 5.7468476,10.850595 C5.9017982,10.568037 5.9792733,10.256617 5.9792733,9.9163332 C5.9792733,9.6246605 5.9230657,9.3664093 5.8106508,9.1415796 C5.6982355,8.916749 5.5448041,8.7283773 5.3503561,8.5764647 C5.1559081,8.4245529 4.9310775,8.3106184 4.6758647,8.2346621 C4.4206519,8.1587057 4.1502476,8.1207275 3.8646524,8.1207275 C2.8377242,8.1207275 1.9475174,8.5248146 1.1940317,9.3329887 L1.1940317,7.7287941 C2.1237359,7.1454496 3.0868607,6.8537779 4.0834064,6.8537779 z" 
                                Grid.Column="1" Grid.Row="3">
                          <Path.RenderTransform>
                            <TransformGroup>
                              <ScaleTransform/>
                              <SkewTransform/>
                              <RotateTransform/>
                              <TranslateTransform/>
                            </TransformGroup>
                          </Path.RenderTransform>
                        </Path>
                        <Rectangle x:Name="rectangle" Fill="{StaticResource Couvercle}" Grid.ColumnSpan="3" Grid.RowSpan="2" 
                                     RenderTransformOrigin="0.5,0.5">
                          <Rectangle.RenderTransform>
                            <TransformGroup>
                              <ScaleTransform/>
                              <SkewTransform/>
                              <RotateTransform/>
                              <TranslateTransform/>
                            </TransformGroup>
                          </Rectangle.RenderTransform>
                        </Rectangle>
                      </Grid>

                      <s:SurfaceButton.Resources>
                        <Storyboard x:Key="PoubelleStoryboard">
                          <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(SolidColorBrush.Color)">
                            <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFF8A00"/>
                            <SplineColorKeyFrame KeyTime="00:00:00.5000000" Value="Red"/>
                            <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFFFA200"/>
                            <SplineColorKeyFrame KeyTime="00:00:01.5000000" Value="Red"/>
                            <SplineColorKeyFrame KeyTime="00:00:02" Value="#FFFF8A00"/>
                          </ColorAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1.204"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1.204"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1.204"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1.204"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
                          </DoubleAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="-0.011"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="-0.011"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
                          </DoubleAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.244"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0.204"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
                          </DoubleAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="-4"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="-5"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.8000000" Value="-5"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
                          </DoubleAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="rectangle" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00.6000000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01" Value="15"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.8000000" Value="-15"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
                          </DoubleAnimationUsingKeyFrames>
                          <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
                            <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="-5"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.5200000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:00.7800000" Value="-8"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.0200000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.2800000" Value="-8"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.5200000" Value="0"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:01.7400000" Value="-8"/>
                            <SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
                          </DoubleAnimationUsingKeyFrames>
                        </Storyboard>
                      </s:SurfaceButton.Resources>

                      <s:SurfaceButton.Style>
                        <Style TargetType="{x:Type s:SurfaceButton}">
                          <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type s:SurfacePopup}}, Path=IsOpen}"
                                          Value="true">
                              <DataTrigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource PoubelleStoryboard}"/>
                              </DataTrigger.EnterActions>
                            </DataTrigger>
                          </Style.Triggers>
                        </Style>
                      </s:SurfaceButton.Style>

                    </s:SurfaceButton>
                  </s:SurfacePopup>

                </Grid>

                <Border.Style>
                  <Style TargetType="{x:Type Border}">
                    <Style.Triggers>

                      <DataTrigger Binding="{Binding Path=Color}" Value="Red">
                        <Setter Property="Background" Value="{StaticResource BookmarkRed}" />
                      </DataTrigger>
                      <DataTrigger Binding="{Binding Path=Color}" Value="Blue">
                        <Setter Property="Background" Value="{StaticResource BookmarkBlue}" />
                      </DataTrigger>
                      <DataTrigger Binding="{Binding Path=Color}" Value="Green">
                        <Setter Property="Background" Value="{StaticResource BookmarkGreen}" />
                      </DataTrigger>
                      <DataTrigger Binding="{Binding Path=Color}" Value="Yellow">
                        <Setter Property="Background" Value="{StaticResource BookmarkYellow}" />
                      </DataTrigger>

                    </Style.Triggers>
                  </Style>
                </Border.Style>
              </Border>

              <s:SurfacePopup x:Name="PART_Popup" Width="230" Height="192" PlacementTarget="{Binding ElementName=PART_Border}" Placement="Top"
                              HorizontalOffset="35" VerticalOffset="6" StaysOpen="False" AllowsTransparency="True">

                <Border>
                  <Border.Style>
                    <Style TargetType="{x:Type Border}">
                      <Style.Triggers>

                        <DataTrigger Binding="{Binding Color}" Value="Red">
                          <Setter Property="Background" Value="{StaticResource EtiquetteRed}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Color}" Value="Blue">
                          <Setter Property="Background" Value="{StaticResource EtiquetteBlue}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Color}" Value="Green">
                          <Setter Property="Background" Value="{StaticResource EtiquetteGreen}" />
                        </DataTrigger>
                        <DataTrigger Binding="{Binding Color}" Value="Yellow">
                          <Setter Property="Background" Value="{StaticResource EtiquetteYellow}" />
                        </DataTrigger>

                      </Style.Triggers>
                    </Style>
                  </Border.Style>

                  <Grid Margin="38,20,10,70">
                    <Grid.RowDefinitions>
                      <RowDefinition Height="0.688*" />
                      <RowDefinition Height="0.312*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                      <ColumnDefinition Width="0.047*" />
                      <ColumnDefinition Width="0.803*" />
                      <ColumnDefinition Width="0.15*" />
                    </Grid.ColumnDefinitions>

                    <Grid.RenderTransform>
                      <RotateTransform Angle="-6" />
                    </Grid.RenderTransform>

                    <s:SurfaceTextBox Text="{Binding Details}" Margin="5,16,5,5" Grid.Column="1" Grid.ColumnSpan="2"  
              				Style="{StaticResource SurfaceTextBoxStyleWidthLargerCorner}" />

                    <s:SurfaceListBox Grid.Row="1" Grid.ColumnSpan="3"
              				ItemsSource="{x:Static local:CustomBookmarkProperties.AllColors}" 
              				SelectedItem="{Binding Color}"
              				ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.VerticalScrollBarVisibility="Hidden" 
              				MinHeight="0" VerticalAlignment="Top" HorizontalAlignment="Center" BorderThickness="0"
              				Margin="0,-2,0,0" Background="Transparent" ItemContainerStyle="{DynamicResource CustomListBoxItemStyle}">

                      <s:SurfaceListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                          <StackPanel Orientation="Horizontal" IsItemsHost="True" />
                        </ItemsPanelTemplate>
                      </s:SurfaceListBox.ItemsPanel>

                      <s:SurfaceListBox.ItemTemplate>
                        <DataTemplate>
                          <s:SurfaceToggleButton x:Name="STB" IsHitTestVisible="False" />

                          <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding .}" Value="Blue">
                              <Setter TargetName="STB" Property="Background" Value="#FD1A86C3" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding .}" Value="Red">
                              <Setter TargetName="STB" Property="Background" Value="#FFDA2C15" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding .}" Value="Green">
                              <Setter TargetName="STB" Property="Background" Value="#FF1EA113" />
                            </DataTrigger>
                            <DataTrigger Binding="{Binding .}" Value="Yellow">
                              <Setter TargetName="STB" Property="Background" Value="#FFD2D200" />
                            </DataTrigger>
                          </DataTemplate.Triggers>
                        </DataTemplate>
                      </s:SurfaceListBox.ItemTemplate>

                    </s:SurfaceListBox>

                  </Grid>

                </Border>

              </s:SurfacePopup>

            </Grid>

          </ControlTemplate>

        </Setter.Value>
      </Setter>

      <Style.Resources>

        <Storyboard x:Key="OnSelectedSB">
          <DoubleAnimation To="60" Storyboard.TargetProperty="Width" Duration="00:00:00.4000000" />
          <DoubleAnimation To="45" Storyboard.TargetProperty="Height" Duration="00:00:00.4000000" />
        </Storyboard>

        <Storyboard x:Key="OnUnselectedSB">
          <DoubleAnimation To="50" Storyboard.TargetProperty="Width" Duration="00:00:00.4000000" />
          <DoubleAnimation To="35" Storyboard.TargetProperty="Height" Duration="00:00:00.4000000" />
        </Storyboard>

      </Style.Resources>

      <Style.Triggers>

        <Trigger Property="Header" Value="{x:Null}">
          <Setter Property="Visibility" Value="Collapsed" />
        </Trigger>

        <Trigger Property="IsSelected" Value="True">

          <Trigger.EnterActions>
            <BeginStoryboard x:Name="OnSelectedBSB" Storyboard="{StaticResource OnSelectedSB}" />
          </Trigger.EnterActions>
          <Trigger.ExitActions>
            <StopStoryboard BeginStoryboardName="OnSelectedBSB" />
            <BeginStoryboard Storyboard="{StaticResource OnUnselectedSB}" />
          </Trigger.ExitActions>

        </Trigger>

      </Style.Triggers>

    </Style>

    <!--<Style TargetType="{x:Type controls:BookPage}">
      <Setter Property="CanDragOutOfPage" Value="false" />
      <Setter Property="DragAngle" Value="45" />
    </Style>-->
    
  </s:SurfaceWindow.Resources>

  <DockPanel>
    <DockPanel.Resources>
      <Style x:Name="title" TargetType="{x:Type Label}">
        <Setter Property="Template">
          <Setter.Value>
            <ControlTemplate>
              <Border BorderThickness="2" BorderBrush="Black" Background="Gray"
                      DockPanel.Dock="Top" HorizontalAlignment="Center" CornerRadius="0 0 5 5" Padding="5 0 5 0"/>
            </ControlTemplate>
          </Setter.Value>
        </Setter>
      </Style>
    </DockPanel.Resources>

    <DockPanel.Background>
      <LinearGradientBrush StartPoint="0 0.4 " EndPoint="1 0.6">
        <GradientStop Offset="0" Color="DarkGray" />
        <GradientStop Offset="0.5" Color="White" />
        <GradientStop Offset="1" Color="DarkGray" />
      </LinearGradientBrush>
    </DockPanel.Background>

    <ToolBarTray DockPanel.Dock="Top">
      <ToolBar Band="0">
        <s:SurfaceButton Click="PreviousClick" Content="Previous sheet"/>
        <s:SurfaceButton Click="NextClick" Content="Next sheet"/>
        <Separator />
        <s:SurfaceButton Click="AutoPreviousClick" Content="Animate to previous sheet"/>
        <s:SurfaceButton Click="AutoNextClick" Content="Animate to next sheet"/>

        <StackPanel>
          <s:SurfaceButton Content="GripSize :" />
          <s:SurfaceSlider Minimum="0" Maximum="100" Value="{Binding GripSize, ElementName=myBook, Mode=TwoWay}" Width="100" />
        </StackPanel>

        <s:SurfaceListBox SelectionChanged="BookmarksPlacement_SelectionChanged" SelectedIndex="1">
          <s:SurfaceListBoxItem Content="Bookmarks Left"/>
          <s:SurfaceListBoxItem Content="Bookmarks Top"/>
          <s:SurfaceListBoxItem Content="Bookmarks Right"/>
          <s:SurfaceListBoxItem Content="Bookmarks Bottom"/>
        </s:SurfaceListBox>

        <StackPanel>
          <s:SurfaceListBox SelectionChanged="BookmarkerPlacement_SelectionChanged" SelectedIndex="1" >
            <s:SurfaceListBoxItem Content="Bookmarker Left"/>
            <s:SurfaceListBoxItem Content="Bookmarker Right"/>
          </s:SurfaceListBox>

          <s:SurfaceListBox x:Name="lbFromTop" SelectedIndex="1">
            <s:SurfaceListBoxItem Content="Anim. from top"/>
            <s:SurfaceListBoxItem Content="Anim. from bottom"/>
          </s:SurfaceListBox>
        </StackPanel>

        <StackPanel>
          <s:SurfaceTextBox Text="{Binding SelectedIndex, ElementName=myBook, Mode=TwoWay}" Width="100" />
          <s:SurfaceListBox SelectionChanged="BookmarksVisibility_SelectionChanged" SelectedIndex="0" >
            <s:SurfaceListBoxItem Content="Bookmarks Visible"/>
            <s:SurfaceListBoxItem Content="Bookmarks Collapsed"/>
            <s:SurfaceListBoxItem Content="Bookmarks Hidden"/>
          </s:SurfaceListBox>
        </StackPanel>

      </ToolBar>
      <ToolBar Band="1">
        <s:SurfaceCheckBox IsChecked="False" Checked="DisplayModeChecked" Unchecked="DisplayModeChecked" Content="Zoom on page" />
        <s:SurfaceButton Click="AutoPreviousPageClick" Content="Auto previous page"/>
        <s:SurfaceButton Click="AutoNextPageClick" Content="Auto next page"/>
      </ToolBar>
    </ToolBarTray>

    <s:ScatterView>
      <s:ScatterViewItem Orientation="0" Center="400,300" Width="700" Height="500">

        <Viewbox Margin="50">
          <Grid>
            <controls:Book x:Name="myBook" PageSize="300,400" BookmarkAdded="myBook_BookmarkAdded">

              <controls:Book.ItemContainerStyle>
                <Style TargetType="{x:Type controls:BookItem}">
                  <Setter Property="Height" Value="40" />
                  <Setter Property="MinWidth" Value="50" />
                  
                  <Style.Triggers>
                    <MultiTrigger>
                      <MultiTrigger.Conditions>
                        <Condition Property="IsSelected" Value="True" />
                        <Condition Property="Header" Value="{x:Null}" />
                      </MultiTrigger.Conditions>
                      <Setter Property="MinWidth" Value="0" />
                    </MultiTrigger>
                  </Style.Triggers>
                </Style>
              </controls:Book.ItemContainerStyle>

              <controls:Book.ContentTemplate>
                <DataTemplate>
                  <Border BorderThickness="4" BorderBrush="Gray" Background="Transparent">
                    <ContentControl Content="{Binding .}" />
                  </Border>
                </DataTemplate>
              </controls:Book.ContentTemplate>

              <controls:BookItem Header="Test">
                <controls:BookItem.Template>
                  <ControlTemplate TargetType="{x:Type controls:BookItem}">

                    <ContentPresenter 
                      x:Name="Content" 
                      HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" 
                      VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" 
                      SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" ContentSource="Header" RecognizesAccessKey="True" />


                  </ControlTemplate>
                </controls:BookItem.Template>
                <controls:BookItem.HeaderTemplate>

                  <DataTemplate>
                    <TextBlock x:Name="Hea" Text="{Binding .}" Background="Red" />
                    <DataTemplate.Triggers>

                      <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:BookItem}}}" Value="True">
                        <Setter Property="Background" Value="Yellow" TargetName="Hea" />
                      </DataTrigger>

                    </DataTemplate.Triggers>
                  </DataTemplate>

                </controls:BookItem.HeaderTemplate>
                <local:UCCube />
              </controls:BookItem>

              <controls:BookItem Header="T">
                <local:UCControls />
              </controls:BookItem>

              <controls:BookItem Header="Test 3">
                <local:UCClippingTransparency />
              </controls:BookItem>

              <controls:BookItem Header="Test 4">
                <local:UCClippingTransparency />
              </controls:BookItem>

              <local:CustomBookItem Header="{StaticResource CustBookmarkRed}" Style="{StaticResource customBookItemStyle}">
                <local:UCClipping />
              </local:CustomBookItem>

              <local:CustomBookItem Style="{StaticResource customBookItemStyle}">
                <local:UCClipping />
              </local:CustomBookItem>

              <local:UCTriggers />
              <local:UCFixedDocument />
              <local:UCDataBindingTransformation />
              <local:UCXaml />
              <local:UCAbout />
              <local:UCTheEnd />

            </controls:Book>
          </Grid>
        </Viewbox>

      </s:ScatterViewItem>
    </s:ScatterView>

  </DockPanel>

</s:SurfaceWindow>
